package com.jason.quectel0805.activities;

import android.os.Bundle;
import android.view.View;

import com.jason.quectel0805.R;
import com.jason.quectel0805.adapters.MyFragmentPagerAdapter;
import com.jason.quectel0805.fragments.HomeFragment;
import com.jason.quectel0805.fragments.MallFragment;
import com.jason.quectel0805.fragments.MineFragment;
import com.jason.quectel0805.fragments.ShoppingFragment;

import java.util.ArrayList;
import java.util.List;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.ViewPager;

/**
 * @author：Jason
 * @date：2022/8/9 12:53
 * @email：1129847330@qq.com
 * @description:
 */
public class ViewPagerActivity extends AppCompatActivity {
    private List<View> list = new ArrayList<>();

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_viewpager);

        ViewPager viewPager = findViewById(R.id.vp_show);
        viewPager.setOffscreenPageLimit(0);
        //LayoutInflater inflater = LayoutInflater.from(this);
        //View view1 = inflater.inflate(R.layout.item, null);
        //View view2 = inflater.inflate(R.layout.activity_main, null);
        //View view3 = inflater.inflate(R.layout.activity_splash, null);
        //list.add(view1);
        //list.add(view2);
        //list.add(view3);
        //MyPagerAdapter myPagerAdapter = new MyPagerAdapter(list);

        List<Fragment> fragmentList = new ArrayList<>();
        fragmentList.add(new HomeFragment());
        fragmentList.add(new MallFragment());
        fragmentList.add(new ShoppingFragment());
        fragmentList.add(new MineFragment());
        MyFragmentPagerAdapter fragmentPagerAdapter = new MyFragmentPagerAdapter(getSupportFragmentManager(), fragmentList);
        viewPager.setAdapter(fragmentPagerAdapter);
    }
}